load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//:defs.bzl", "make_signames")

VERSION = "23.7"

defines = [
    "WITH_STATX",
    "WITH_IPV6",
    "HAVE_LOCALE_H",
    "VERSION='\"{}\"'".format(VERSION),
]

make_signames(
    name = "signames.h",
)

cc_binary(
    name = "fuser",
    srcs = [
        "signames.h",
        "src/comm.h",
        "src/fuser.c",
        "src/fuser.h",
        "src/i18n.h",
        "src/lists.h",
        "src/signals.c",
        "src/signals.h",
        "src/statx.c",
        "src/statx.h",
    ],
    copts = [
        "-Wno-unused-parameter",
        "-Wno-format",
    ],
    local_defines = defines,
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "killall",
    srcs = [
        "signames.h",
        "src/comm.h",
        "src/i18n.h",
        "src/killall.c",
        "src/signals.c",
        "src/signals.h",
    ],
    copts = ["-Wno-format"],
    linkopts = ["-ldl"],
    local_defines = defines,
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "pslog",
    srcs = [
        "src/i18n.h",
        "src/pslog.c",
    ],
    local_defines = defines,
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "pstree",
    srcs = [
        "src/comm.h",
        "src/i18n.h",
        "src/pstree.c",
    ],
    copts = ["-Wno-sign-compare"],
    local_defines = defines,
    visibility = ["//visibility:public"],
    deps = ["@ncurses"],
)

cc_binary(
    name = "prtstat",
    srcs = [
        "src/i18n.h",
        "src/prtstat.c",
        "src/prtstat.h",
    ],
    copts = ["-Wno-format"],
    local_defines = defines,
    visibility = ["//visibility:public"],
)
